﻿// Write a program that reads from the console a sequence of N integer numbers and returns the minimal and maximal of them.

using System;

class FindMinAndMaxOfNNumbers
{
    static void Main()
    {
        int minNumber = int.MaxValue;
        int maxNumber = int.MinValue;

        Console.Write("Please, say how many numbers you want to enter: ");
        string countNumbersStr = Console.ReadLine();
        uint countNumbers;
        while (!uint.TryParse(countNumbersStr, out countNumbers))
        {
            Console.Write("Invalid input. Please, say how many number you want to enter : ");
            countNumbersStr = Console.ReadLine();
        }

        for (int i = 1; i <= countNumbers; i++)
        {
            Console.Write("Enter number : ");
            string numberStr = Console.ReadLine();
            int number;
            while (!int.TryParse(numberStr, out number))
            {
                Console.Write("Invalid input. Please, enter your number again : ");
                numberStr = Console.ReadLine();
            }

            if (number < minNumber)
            {
                minNumber = number;
            }
            if (number > maxNumber)
            {
                maxNumber = number;
            }
        }

        Console.WriteLine("The minimal entered number is {0} and the maximal entered number is {1}.", minNumber, maxNumber);
    }
}
